#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> nums(n, 0);
    int noZero = 0;
    for (int i = 0; i < n; ++i) {
        cin >> nums[i];
        if (nums[i] != 0) {
            noZero++;
        }
    }
    if (x >= n) {
        cout << noZero << endl;
        return 0;
    }
    sort(nums.begin(), nums.end(), [&](int a, int b) -> bool {
        return a > b;
    });
    int score = nums[x - 1];
    if (score == 0) {
        cout << noZero << endl;
        return 0;
    }
    for (int i = x; i < n; ++i) {
        if (score > nums[i]) {
            break;
        }
        x++;
    }
    cout << x << endl;
    return 0;
}